package com.wingice.system.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;

import java.io.Serializable;

/**
 * <p>
 * 资源信息
 * </p>
 *
 * @author 胡昊
 * @since 2020-07-23
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "SysResource对象")
public class SysResource implements Serializable, GrantedAuthority {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "id")
    private String id;

    @Schema(description = "资源名称")
    private String name;

    @Schema(description = "资源标识符")
    private String permission;

    @Schema(description = "父资源id")
    private String parentId;

    @Schema(description = "图标")
    private String icon;

    @Schema(description = "路由缓冲 0-关闭 1-开启")
    private Integer keepAlive;

    @Schema(description = "资源类型（0左菜单 1顶菜单 2按钮）")
    private Integer type;

    @Schema(description = "路径")
    private String path;

    @Schema(description = "组件路径")
    private String component;

    @Schema(description = "是否展示 0-不展示 1-展示")
    private Integer showType;

    @Schema(description = "终端类型（预留字段）")
    private Integer clientType;

    @Schema(description = "菜单类型（预留字段）")
    private Integer menuType;

    @Schema(description = "资源类型（预留字段）")
    private Integer resourceType;

    @Schema(description = "资源名称（预留字段）")
    private String resourceName;

    @Schema(description = "权限名称（预留字段）")
    private String permissionName;

    @Schema(description = "服务id（预留字段）")
    private String serviceId;

    @Schema(description = "服务名称（预留字段）")
    private String serviceName;

    @Schema(description = "权重")
    private Integer weight;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    private Long createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间")
    private Long updateTime;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建者")
    private String createBy;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新者")
    private String updateBy;

    @Version
    @Schema(description = "版本")
    private Long version;

    @TableLogic
    @Schema(description = "是否有效 0-未删除 1-已删除")
    private Integer deleted;

    @Schema(description = "额外信息")
    private String extra;

    @Schema(description = "租户id")
    private String tenantId;

    @Override
    public String getAuthority() {
        return permission;
    }
}
